package main.java.jdk8;

import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;

/**
 * 数组并行支持
 * 
 * @author Zhzhl
 *
 */
public class ArraysParallelTest {

	public static void main(String[] args) {
		long[] arrayOfLong = new long[20000];

		// 初始化
		Arrays.parallelSetAll(arrayOfLong, index -> arrayOfLong[index] = ThreadLocalRandom.current().nextInt(1000000));

		// 未排序之前
		Arrays.stream(arrayOfLong).limit(10).forEach(i -> System.out.print(i + " "));
		System.out.println();

		// 排序之后
		Arrays.parallelSort(arrayOfLong);
		Arrays.stream(arrayOfLong).limit(10).forEach(i -> System.out.print(i + " "));
		System.out.println();
	}
}
